package com.inspur.edp.bff.spi.action.save;

import com.inspur.edp.bef.api.lcp.IStandardLcp;
import com.inspur.edp.bff.api.manager.context.SaveContext;
import com.inspur.edp.bff.api.manager.context.TimeStampContext;
import com.inspur.edp.bff.spi.AbstractFSAction;
import com.inspur.edp.cef.api.VoidReturnType;

public class DefaultSaveAction extends AbstractFSAction<VoidReturnType> {

    private SaveContext saveContext;

    public DefaultSaveAction(SaveContext context) {
        saveContext = context;
    }

    protected final SaveContext getSaveContext() {
        return saveContext;
    }

    @Override
    protected void execute() {
        //获取外部服务传过来的上下文信息
        TimeStampContext context = getContext().getBffManager().getTimeStampContext();
        for (IStandardLcp lcp : getContext().getLcps().values()) {
            lcp.getBefContext()
                    .setEnableTimeStampLastModifiedBy(context.isEnableTimeStampLastModifiedBy());
            lcp.save();
        }
    }
}
